/***************************************************************************
 *   Copyright (C) 2010 by Oleg Goncharov  *
 *   $EMAIL$                           *                          
 *                                                                         *
 *   This file is part of ChessVision.                                     *
 *                                                                         *
 *   ChessVision is free software; you can redistribute it and/or modify   *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef KATANACKATANAWITHEYE_H
#define KATANACKATANAWITHEYE_H

#include <kniBase.h>

#include "vision/geomtypes.h"
#include "vision/cimagesource.h"
#include "vision/cpointdetector.h"
#include "vision/ccamtransform.h"

namespace Katana {

/**
Katana + камера + преобразование координат.

	@author Goncharov Oleg <goncharovoi@yandex.ru>
*/
class CKatanaWithEye{
protected:
	CImageSource& cam;
	CikBase& katana;
	CCamTransform& transform;
	CPointDetector& detector;

public:
	Path3D recalibration_path;
	bool shift_recal_path;
	
	CKatanaWithEye(CikBase& _katana, CImageSource& _cam, CPointDetector& det, CCamTransform& _tr);
	~CKatanaWithEye();
	
	const CCamTransform& GetTransform() { return transform; }
	CikBase& GetKatana() { return katana; }
	CImageSource& GetEye() { return cam; }
	
	void Calibrate();
	void Calibrate(const Path3D& points);
	
	bool CheckTransform(float threshold, const Path3D& recalibrate_path, bool shift_path = false, bool recalibrate = true);
	bool CheckTransform(float threshold, bool recalubrate = true);
	
	void movToImagePoint(const cv::Point2f& point, const HPlane3f& plane, double theta, bool wait = false, int waittime = 0);
protected:
	void ReCalibrate(const Path3D& path, bool shift_path);
};

}

#endif
